Release 10.1A: OpenEdge Data Management:
DataServer for ORACLE
Indexes
You create and maintain all indexes from within ORACLE. When you create a schema image from a target ORACLE database, OpenEdge automatically copies the ORACLE index definitions.
Indexes allow you to use the
OFkeyword in the Progress 4GLwithFOREACHandFINDstatements. Using theOFkeyword improves the readability of your code. TheOFkeyword is a shorter version of aWHEREclause. You can useOFonly when you have a field of the same name in two tables and this field is a unique index in at least one of the tables. You can then write the following statement:
Index definitions support the Progress 4GL
USE-INDEXmodifier. The Progress 4GL translatesUSE-INDEXtoORDERBYfor DataServer operations. For example, if you definecity-deptas an index on thecityanddepartmentfields, the following Progress 4GL statements are equivalent when accessing an ORACLE database:
Note: If you do not specify
USE-INDEX, your query will return records in an unpredictable order. Your application might not require predictable ordering, but if it does, be sure to includeUSE-INDEXin your query definition.ORACLE chooses which index, if any, to use when the OpenEdge application accesses information in the ORACLE database. However, the DataServer passes an index hint to ORACLE that specifies the index to use for a query and in which order to read the index. The hints take the form of comments in the SQL code generated by the DataServer.
The DataServer issues index hints to ORACLE according to two guidelines:
- If you use the Progress 4GL
USE-INDEXmodifier in your code, the DataServer generates a hint telling ORACLE which to use. The DataServer considers the direction of your query and whether you declared the first component of your index to be ascending or descending. The DataServer then issues an SQL statement to ORACLE that it should read the index either forward or backward to ensure that it retrieves the records in the order you specified.By including the
USE-INDEXmodifier in your Progress 4GL code, you can enhance ORACLE performance, especially in cases where your application returns records in a descending order.- If you do not use the Progress 4GL
USE-INDEXmodifier, the DataServer might generate an index hint based upon theWHEREorBYoption. If theWHEREclause has one of the following elements, the DataServer generates an index hint based on theBYoption:
- The not equal operator (< >).
- A function.
- An expression.
For example, the DataServer passes an index hint to ORACLE to use
cust-numfor the following query:
If you issue a query that includes
BYoptions, the DataServer considers whether the fields for theBYoption participate in a compound index and generates an index hint to ORACLE to use that index if theWHEREclause does not imply a different index.You can prevent the DataServer from passing hints to ORACLE by using the
Note: The Progress 4GLNO-INDEX-HINToption for theQUERY-TUNINGphrase or by using the-noindexhintstartup parameter. See the "Query tuning" section and the "ORACLE hints" section for more information.INDEX-INFORMATIONcannot be used against the ORACLE DataServer. The DataServer does not inform the 4GL which index or indexes ORACLE uses to perform a query, therefore this attribute does not contain any valid information.Leading and trailing spaces
The Progress 4GL and ORACLE handle leading or trailing blanks in an indexed column differently. For example, when you attempt to create a record in ORACLE and include leading or trailing blanks in a column that participates in a unique index, ORACLE returns a message that there is a duplicate unique key. To address this, the DataServer, by default, trims leading or trailing blanks when you use them in a
WHEREclause. If you want to specify leading or trailing blanks, specify the-znotrimstartup parameter when you start the OpenEdge client session.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |